package com.tencent.ncnnyolox.basemodule.base.dialog

import android.content.Context
import android.os.CountDownTimer
import android.util.Log
import android.view.Gravity
import com.tencent.ncnnyolox.R
import com.tencent.ncnnyolox.basemodule.base.BaseDialog
import com.tencent.ncnnyolox.basemodule.base.action.AnimAction

/**
 * <pre>
 *     author : yh
 *     e-mail : xxx@xx
 *     time   : 2023/12/22
 *     desc   :
 * </pre>
 */
class NetErrorDialog {
        open class Builder(context: Context) : BaseDialog.Builder<CommonTempDialog.Builder>(context) {
        init {
            setContentView(R.layout.error_dialog)
            setAnimStyle(AnimAction.ANIM_BOTTOM)
            setGravity(Gravity.CENTER)

        }


        fun setShow(): Builder {
            val TotalTime: Long = 3 * 1000
            val countDownTimer = object : CountDownTimer(TotalTime, 1000) {
                //1000ms运行一次onTick里面的方法
                override fun onFinish() {
                    dismiss()
                    Log.d("NetErrorDialog", "==倒计时结束")
                }

                override fun onTick(millisUntilFinished: Long) {
                    val hour = millisUntilFinished / 1000 / 60 / 60
                    val minute = millisUntilFinished / 1000 / 60 % 60
                    val second = millisUntilFinished / 1000 % 60
                    Log.d("NetErrorDialog", "==倒计时" + hour + "小时" + minute + "分" + second + "秒")
                }
            }.start()


            return this
        }
    }
}